//
//  SixViewController.m
//  UI_元旦豆瓣小集合
//
//  Created by dllo on 16/1/2.
//  Copyright © 2016年 lanou3g. All rights reserved.
//

#import "SixViewController.h"
#import "My1model.h"
#import "UIImageView+WebCache.h"
#import "Mytitlemodel.h"
#import "ADataBaseHandle.h"
#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height
@interface SixViewController ()<UIScrollViewDelegate>


@property (nonatomic, retain) UIScrollView *scrollView;

@end

@implementation SixViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    My1model *model = _jie[_index.row];

    self.title = model.title;

    UIScrollView *Sview = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    Sview.contentSize = CGSizeMake(0, HEIGHT * 2.8);
    [self.view addSubview:Sview];
    
    UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(20, 30, 250, 30)];
//    label1.backgroundColor = [UIColor redColor];
    label1.text = model.title;
    [Sview addSubview:label1];
    [label1 release];
    
    UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(170, 90, 180, 30)];
//    label2.backgroundColor = [UIColor redColor];
    label2.text = model.begin_time;
    [Sview addSubview:label2];
    [label2 release];
    
    UILabel *label3 = [[UILabel alloc] initWithFrame:CGRectMake(170, 120, 130, 30)];
//    label3.backgroundColor = [UIColor redColor];
    label3.text = model.address;
    [Sview addSubview:label3];
    [label3 release];

    UILabel *label4 = [[UILabel alloc] initWithFrame:CGRectMake(170, 150, 150, 30)];
    label4.text = [NSString stringWithFormat:@"类型:%@", model.category_name];
    
    [Sview addSubview:label4];
    [label4 release];

    UILabel *label5 = [[UILabel alloc] initWithFrame:CGRectMake(170, 130, 200, 150)];
//    label5.backgroundColor = [UIColor redColor];
    label5.text = model.address;
    label5.numberOfLines = 3;
    [Sview addSubview:label5];
    [label5 release];

    UILabel *label6 = [[UILabel alloc] initWithFrame:CGRectMake(20, 255, 100, 30)];
//    label6.backgroundColor = [UIColor redColor];
    label6.text = @"活动介绍";
    label6.font = [UIFont systemFontOfSize:20];
    [Sview addSubview:label6];
    [label6 release];

    UILabel *label7 = [[UILabel alloc] initWithFrame:CGRectMake(20, 180, 320, 1700)];
//    label7.backgroundColor = [UIColor redColor];
    label7.text = model.content;
    label7.numberOfLines = 200;
    [Sview addSubview:label7];
    [label7 release];
   
    UIImageView *view1 = [[UIImageView alloc] init];
    view1.frame = CGRectMake(140, 90, 30, 30);
//    view1.backgroundColor = [UIColor redColor];
    view1.image = [UIImage imageNamed:@"10.png"];
    [Sview addSubview:view1];
    [view1 release];
    
    UIImageView *view2 = [[UIImageView alloc] init];
    view2.frame = CGRectMake(140, 120, 30, 30);
//    view2.backgroundColor = [UIColor yellowColor];
    view2.image = [UIImage imageNamed:@"12.png"];
    [Sview addSubview:view2];
    [view2 release];
    
    UIImageView *view3 = [[UIImageView alloc] init];
    view3.frame = CGRectMake(140, 150, 30, 30);
//    view3.backgroundColor = [UIColor greenColor];
    view3.image = [UIImage imageNamed:@"15.png"];
    [Sview addSubview:view3];
    [view3 release];

    
    UIImageView *view4 = [[UIImageView alloc] init];
//    view4.backgroundColor = [UIColor redColor];
    view4.frame = CGRectMake(140, 180, 30, 30);
    view4.image = [UIImage imageNamed:@"11.png"];
    [Sview addSubview:view4];
    [view4 release];

    
    UIImageView *view5 = [[UIImageView alloc] init];
    view5.backgroundColor = [UIColor blackColor];
    [view5 sd_setImageWithURL:[NSURL URLWithString:model.image]];
    view5.frame = CGRectMake(20, 90, 100, 150);
    [Sview addSubview:view5];
    [view5 release];
    
    UIBarButtonItem *rightItme = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"right.png"] style:UIBarButtonItemStyleDone target:self action:@selector(rightAction:)];
    rightItme.tintColor = [UIColor whiteColor];
    self.navigationItem.rightBarButtonItem = rightItme;
    
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"left.png"] style:UIBarButtonItemStyleDone target:self action:@selector(leftAction:)];
    leftItem.tintColor = [UIColor whiteColor];
    self.navigationItem.leftBarButtonItem = leftItem;


}
- (void) rightAction:(UIBarButtonItem *) right {
     Mytitlemodel *model = [Mytitlemodel mytitlemodel];
     My1model *model1 = _jie[_index.row];
    NSArray *arr = [[ADataBaseHandle sharedDaseBaseHandle] selectModel];
    if (![arr containsObject:model1.title]) {
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"收藏成功" preferredStyle:UIAlertControllerStyleAlert];
   
       
    UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"确定"  style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    model.title = model1.title;
        
    [[ADataBaseHandle sharedDaseBaseHandle] insetrModel:model];
    }];
    [alert addAction:alertAction];
   [self presentViewController:alert animated:YES completion:^{
       
   }];

    }else{
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"已经收藏" preferredStyle:UIAlertControllerStyleAlert];
        [self presentViewController:alert animated:YES completion:^{
            [self dismissViewControllerAnimated:YES completion:^{
                
            }];
        }];
    }
       
   }

- (void) leftAction:(UIBarButtonItem *) left {
    [self.navigationController popToRootViewControllerAnimated:YES];

    }

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
   
    
}




@end
